<?

	include_once("cmsConfig.php");
	//include("cmsMail")
	// we need to decide if we are having a mailout that is new, or editing and existing one..
	//get the newletter/mailout from the session, or create one, if we dont have it..

	//this page needs to ummm... figureout what class we are using
	// and then try and load/create one..
	//the class will be sucked in as either
	// a formid or perhaps a um..class name.. not sure..
	
	
	//we expect the various things to set this up to be living in the session..
	//possibly passed in.. in the future..
	$cmsKvcName = extractStringWithKeyFromArray('cmsKvcName', $_SESSION);
	$cmsKvcClass = extractStringWithKeyFromArray('cmsKvcClass', $_SESSION);

	
	$cmsKvcO = extractObjectWithKeyOfClassFromArray($cmsKvcName,$cmsKvcClass, $_SESSION, null);
	if (is_null($cmsKvcO) && !is_null($cmsKvcClass) && strlen($cmsKvcClass)>0 && class_exists($cmsKvcClass)) {
		$cmsKvcO = new $cmsKvcClass();
		$_SESSION[$cmsKvcName] = &$cmsKvcO;
	}
	
	if ( is_null($cmsKvcO))
		die("no cmskvc object");
		//return;
		
	$id = extractStringWithKeyFromArray('id',$_REQUEST,null);
	
	//if we have a kvcid.. we either load.. or take the values from the request...
	//hope that this still works with mailout stuff..
	if (!is_null($id) && strlen($id) == 8) {
		$cmsKvcO->load($id, $authInfo, $db );
	} else {
		$cmsKvcO->takeValuesFromRequest();
	}

	$cmsKvcO->invokeActions();

	// how do we do this magically.. as we may want to in the future invoke other things from the
	// same place
	echo $cmsKvcO->generateForm($db);// the form will know what items are valid and what ones are not.

	//need to protect this some how.. forgets the method to the madness
	$_SESSION[$cmsKvcName] = &$cmsKvcO;
	//myPrintR($cmsKvcO);

	//myPrintR($_REQUEST);